package com.example.day09;

import com.example.day10.DBCPDatasource;
import com.mysql.jdbc.Driver;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;

public class Update {
    public static void main(String[] args) throws SQLException {
        new Driver();
        Connection connection = DBCPDatasource.getConnection();
        String sql = "UPDATE db_test.student SET age = ? WHERE id = 1";
        PreparedStatement preparedStatement = connection.prepareStatement(sql);
        preparedStatement.setInt(1, 20);
        preparedStatement.executeUpdate();
    }
}
